<template>
	<view>
		<view>
			<button type="primary" @click="chooseImg">上传图片</button>
		</view>
		<image v-for="item in imgArr" :src="item" @click="previewImg(item)"></image>
		<!-- #ifdef H5-->
		<view>我只在h5页面中显示</view>
		<!-- #endif-->
		<!-- #ifdef MP-WEIXIN -->
		<view>我只在微信小程序页面中显示</view>
		<!-- #endif -->
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgArr: []
			}
		},
		methods: {
			chooseImg() {
				console.log('上传图片')
				uni.chooseImage({
					count: 5,
					success: res => {
						this.imgArr = res.tempFilePaths
						console.log(res)
					}
				})
			},
			previewImg(current) {
				console.log(current)
				uni.previewImage({
					current,
					urls: this.imgArr,
					loop:true,
					indicator:"number"
				})
			}
		},
		onLoad() {
			// #ifdef H5
			console.log('我希望H5中打印')
			// #endif
			// #ifdef MP-WEIXIN
			console.log('我希望微信小程序中打印')
			// #endif
			
		}
	}
</script>

<style>

</style>
